package com.ynny.dao;

import com.ynny.bean.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CourseDaoImpl implements CourseDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;


    @Override
    public List<Course> selectAll() {
        String sql = "select * from course";
        List<Course> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Course.class));
        return list;


    }

    @Override
    public int updateCourse(Integer movive, Integer AD, Integer PR) {
        String sql = "update course set movive=?,AD=?,PR=? where courseName='java'";
        int update = jdbcTemplate.update(sql, movive, AD, PR);

        return update;
    }
}
